package kr.hkit.androidcomplete01.ch11;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class EditSelectEx extends Activity {
	
	private EditText mEdit;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.ch11_editselectex);
		
		mEdit = (EditText) findViewById(R.id.edit);
		
	}
	
	public void mOnClick(View v) {
		
		switch (v.getId()) {
		case R.id.home:
			mEdit.setSelection(0);
			break;
		case R.id.end:
			mEdit.setSelection(mEdit.getText().length());
			break;
		case R.id.selblock:
			mEdit.setSelection(3, 10);
			break;
		case R.id.selall:
			mEdit.selectAll();
			break;
		case R.id.getsel:
			int start = mEdit.getSelectionStart();
			int end = mEdit.getSelectionEnd();
			Toast.makeText(EditSelectEx.this, "start=" + start + ", "
					+ "end= " + end, Toast.LENGTH_LONG).show();
			break;
		}
	}
}
